package cn.copera.dyy.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonIgnore;

import cn.copera.dyy.common.persistence.IdEntity;

/**
 * 日志信息
 * @author Administrator
 *
 */
@Entity
@Table(name = "log")
@DynamicInsert
@DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Log extends IdEntity<Log> {
	private static final long serialVersionUID = 1L;
	private Shop shop;// 店铺
	private String openid;// 用户关注OPENID
	private String trackTime;//日志创建时间
	private String content;//日志内容
	private ExchangeRule rule;//规则
	private String checkorno;// 是否兑换
	private String type;//标志。1为记录足迹，2兑换卡点，3为点赞，4为分享
	private Date validDate;//申请兑换有效期
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "shop_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@JsonIgnore	
	public Shop getShop() {
		return shop;
	}
	public void setShop(Shop shop) {
		this.shop = shop;
	}
	public String getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	public String getTrackTime() {
		return trackTime;
	}
	public void setTrackTime(String trackTime) {
		this.trackTime = trackTime;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "rule_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@JsonIgnore		
	public ExchangeRule getRule() {
		return rule;
	}
	public void setRule(ExchangeRule rule) {
		this.rule = rule;
	}
	public String getCheckorno() {
		return checkorno;
	}
	public void setCheckorno(String checkorno) {
		this.checkorno = checkorno;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public Date getValidDate() {
		return validDate;
	}
	public void setValidDate(Date validDate) {
		this.validDate = validDate;
	}
	
	
}
